#include <iostream>
#include <ctime>
#include <unistd.h>
#include "ThreadPool.hpp"
#include "Task.hpp"

//1.这个线程池怎么用？ 主线程生产任务，然后交给线程池里的线程去执行
int main()
{
    srand(time(nullptr));
    //创建线程池
    // ThreadPool<Task>* tp = ThreadPool<Task>::GetThreadPool(5);
    //启动线程池
    ThreadPool<Task>::GetThreadPool(5)->Start();
    while(true)
    {
        //这里负责生产任务
        int data1 = rand() % 10;
        int data2 = rand() % 3;
        char op = oper[rand()%oper.size()];
        Task task(data1, data2, op);
        ThreadPool<Task>::GetThreadPool(5)->Push(task);
        std::cout << "main thread 生产了一个任务: " << task.GetTask() << std::endl; 
        sleep(1);
        
    }
    return 0;
}